import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getx_learn/app/modules/state_manager_demo/modules/bindings_demo/bindings/bindings_demo_binding.dart';
import 'package:getx_learn/app/modules/state_manager_demo/modules/getx_service_demo/services/GlobalConfigService.dart';
import 'package:getx_learn/generated/locales.g.dart';
import 'package:getx_learn/global.dart';
import 'app/routes/app_pages.dart';

void main() async {
  await initServices();
  runApp(
    GetMaterialApp(
      debugShowCheckedModeBanner: false,
      // 去掉那个测试的debug标识
      title: "Application",
      initialRoute: AppPages.INITIAL,
      // 初始化路由
      getPages: AppPages.routes,
      // 所有路由
      defaultTransition: Transition.rightToLeft,
      // 默认的转场动画
      unknownRoute: AppPages.UN_KNOW,

      // 多语言配置 start
      // 设置默认语言
      locale: Locale('zh', 'CN'),
      // 在配置错误的情况下,使用的语言
      fallbackLocale: Locale('zh', 'CN'),
      // 多语言配置文件
      translationsKeys: AppTranslation.translations,
      // 多语言配置 end

      initialBinding: BindingsDemoBinding(), // 这里进行所有的Controller绑定

      navigatorObservers: [Global.routeObserver],

      theme: ThemeData(
        primarySwatch: Colors.green,

        // 设置底部弹出框的背景色为透明
        bottomSheetTheme: const BottomSheetThemeData(
          backgroundColor: Colors.transparent,
        ),
      ),
    ),
  );
}

/**
 * 初始化 GetxService
 */
Future<void> initServices() async {
  print('starting services ...');
  await Get.putAsync(() => GlobalConfigService().init());
  // await Get.putAsync(SettingsService()).init();
  print('All services started...');
}
